package com.villaday.idf.adapter;

import android.content.Context;
import android.os.Build;
import androidx.annotation.RequiresApi;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.OnAdapterCallbackListener;
import com.villaday.idf.custom.SlideRecyclerView;
import com.villaday.idf.model.ordersEntity;
import com.villaday.idf.model3.Add_brokerage_boostersEntity;
import com.villaday.idf.util.PhoneUtil;
import com.villaday.idf.util.SharedPreferencesUtil;

/**
 * 加返记录
 */

public class JiafanJiluAdapter extends AbsRecyclerViewAdapter<Add_brokerage_boostersEntity.BodyEntity.ListEntity> {
    private OnAdapterCallbackListener onAdapterCallbackListener;
    private View.OnClickListener onClickListener;
    private Context mContext;
    LinearLayout llContent;
    SlideRecyclerView slideRecyclerView;


    public JiafanJiluAdapter(Context context, OnAdapterCallbackListener onAdapterCallbackListener) {
        super(context, R.layout.item_jiafan_jl, R.layout.item_page_loading_bg_alpha,
                R.layout.item_page_bottom);
        this.mContext = context;
        this.onAdapterCallbackListener = onAdapterCallbackListener;

    }




    @Override
    public int getItemType(Add_brokerage_boostersEntity.BodyEntity.ListEntity d) {
        return d.getMyType();
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    public void onBindHolder(final AbsRecyclerViewAdapter.RecyclerViewHolder holder, final Add_brokerage_boostersEntity.BodyEntity.ListEntity d, final int position) {



        switch (d.getMyType()) {

            case 0: {//
holder.bindSimpleDraweeView(R.id.sdv_vip,d.getMember().getHeaderUrl())
        .bindTextView(R.id.tv_title,d.getMember().getNickName())
        .bindTextView(R.id.tv_date,d.getCreateTime())
        .bindTextView(R.id.tv_num,d.getUnfrozenAmountValue()+"元");


            }
            break;

            case 1: {
                onAdapterCallbackListener.onCallback();
            }
            break;


        }
    }


    public OnSwipeItemDelClickListener onSwipeItemDelClickListener;
    private boolean isAllowSwipe = false;

    /*    *//*
    public void removeItemByPosition(int position) {
        mdatas.remove(position);
        notifyItemRemoved(position);
        //重新排列数据
        notifyItemRangeChanged(position, mdatas.size());
    }*/


    public boolean isAllowSwipe() {
        return isAllowSwipe;
    }

    public void setAllowSwipe(boolean allowSwipe) {
        isAllowSwipe = allowSwipe;
    }

    public void setOnSwipeItemDelClickListener(OnSwipeItemDelClickListener onSwipeItemDelClickListener) {
        this.onSwipeItemDelClickListener = onSwipeItemDelClickListener;
    }

    interface OnSwipeItemDelClickListener {
        void delItem(int position);
    }

}
